package es.mansoftware.rv;

import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;

public class RvAppWidgetProvider extends AppWidgetProvider {

	@Override
	public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
		//Solo se inicia el reproductor cuando dan ok

		Intent presionarPlay = new Intent(context, ControladorOraciones.class);
		PendingIntent pendingIntent = PendingIntent.getService(context, 0, presionarPlay, 0);
		RemoteViews vista = new RemoteViews(context.getPackageName(), R.layout.rv_play);
		vista.setOnClickPendingIntent(R.id.boton_play, pendingIntent);	
		
		appWidgetManager.updateAppWidget(appWidgetIds, vista);
	}
	
	@Override
	public void onDisabled(Context context){
		Intent intent = new Intent(context, ControladorOraciones.class);
		context.stopService(intent);
	}
}
